import React from 'react'
import { Navigate } from 'react-router-dom'

// 导航守卫
const withControl = (Wrapped: any) => {
  return class extends React.Component {
    render() {
      const token = localStorage.getItem('token')
      return <>{token ? <Wrapped {...this.props}></Wrapped> : <Navigate to="/"></Navigate>}</>
    }
  }
}

export default withControl
